<!DOCTYPE html>
<html lang="en">
<!-- 
  TEMPLATE EXAMPLE: CONDITIONALS
  This example demonstrates how to use conditional (if/else) logic in templates.
-->

<!-- Define variables for conditional tests -->
<!-- template:var title="Conditionals Example" is_logged_in="1" is_admin="0" has_subscription="yes" status="active" empty_var="" -->

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{title}}</title>
    <style>
        :root {
            --bg-primary: #0f0f0f;
            --bg-secondary: #171717;
            --card-bg: #1c1c1c;
            --accent-color: #5d5fef;
            --accent-hover: #4a4ae0;
            --text-primary: #f3f3f3;
            --text-secondary: #b0b0b0;
            --green: #2ed573;
            --green-bg: rgba(46, 213, 115, 0.15);
            --blue: #4f46e5;
            --blue-bg: rgba(79, 70, 229, 0.15);
            --code-bg: #252525;
            --red: #ff4757;
            --red-bg: rgba(255, 71, 87, 0.15);
        }
        
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.5;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }
        
        .container {
            width: 90%;
            max-width: 1100px;
            margin: 0 auto;
            padding: 0;
        }
        
        header {
            padding: 2rem 0 1rem;
            text-align: center;
        }
        
        .content {
            flex: 1;
            padding: 1rem 0 3rem;
        }
        
        h1 {
            color: var(--accent-color);
            margin-bottom: 1.5rem;
            font-size: 2.2rem;
            font-weight: 700;
        }
        
        h2 {
            margin: 0 0 1rem;
            font-size: 1.5rem;
            font-weight: 600;
            color: var(--text-primary);
        }
        
        h3 {
            margin: 1.5rem 0 0.8rem;
            font-size: 1.2rem;
            font-weight: 600;
            color: var(--text-secondary);
        }
        
        p {
            margin-bottom: 1rem;
            color: var(--text-primary);
        }
        
        strong {
            color: var(--accent-color);
            font-weight: 600;
        }
        
        /* Card styles */
        .example {
            background-color: var(--card-bg);
            border-radius: 8px;
            overflow: hidden;
            margin-bottom: 1.5rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.05);
        }
        
        /* Navigation */
        .nav-bar {
            background-color: var(--card-bg);
            padding: 0.75rem 1rem;
            margin-bottom: 2rem;
            border-radius: 8px;
            display: flex;
            align-items: center;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.05);
        }
        
        .nav-bar a {
            color: var(--text-primary);
            text-decoration: none;
            padding: 0.5rem 1rem;
            border-radius: 4px;
            margin-right: 0.5rem;
            transition: all 0.2s ease;
        }
        
        .nav-bar a:hover {
            background-color: rgba(79, 70, 229, 0.15);
            color: var(--accent-color);
        }
        
        .nav-bar a.active {
            background-color: var(--accent-color);
            color: white;
            font-weight: 500;
        }
        
        .nav-back {
            margin-left: auto;
            background-color: rgba(46, 213, 115, 0.15);
            color: var(--green) !important;
        }
        
        .nav-back:hover {
            background-color: rgba(46, 213, 115, 0.3) !important;
        }
        
        /* Code blocks */
        .code {
            background-color: var(--code-bg);
            border-radius: 6px;
            padding: 1rem;
            font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
            font-size: 0.9rem;
            margin-top: 0.5rem;
            border: 1px solid rgba(255, 255, 255, 0.1);
            overflow-x: auto;
        }
        
        .code p {
            margin-bottom: 0.75rem;
        }
        
        .code p:last-child {
            margin-bottom: 0;
        }
        
        /* Lists */
        ul, ol {
            margin-left: 1.5rem;
            margin-bottom: 1.2rem;
        }
        
        li {
            margin-bottom: 0.5rem;
            color: var(--text-primary);
        }
        
        /* True/False styling */
        .true {
            color: var(--green);
            font-weight: 500;
        }
        
        .false {
            color: var(--red);
            font-weight: 500;
        }
        
        footer {
            text-align: center;
            padding: 1.5rem 0;
            background-color: var(--bg-secondary);
            color: var(--text-secondary);
            font-size: 0.9rem;
            margin-top: auto;
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>{{title}}</h1>
        </header>
        
        <div class="content">
            <div class="nav-bar">
                <a href="/variables">Variables</a>
                <a href="/conditionals" class="active">Conditionals</a>
                <a href="/loops">Loops</a>
                <a href="/conditional-loops">Conditional Loops</a>
                <a href="/sql">SQLite</a>
                <a href="/" class="nav-back">Back to Home</a>
            </div>
            
            <div class="example">
                <h2>Basic If Statement</h2>
                
                <p class="true">User is logged in (value: {{is_logged_in}})</p>
                
                <p class="false">User is not an admin (value: {{is_admin}})</p>
                
                <h3>How it works:</h3>
                <div class="code">
                    <p>Define condition variables:<br>
                    &lt;!-- template:var is_logged_in="1" is_admin="0" --&gt;</p>
                    
                    <p>Basic if statement:<br>
                    &#123;% if is_logged_in %&#125;<br>
                    &nbsp;&nbsp;User is logged in.<br>
                    &#123;% endif %&#125;</p>
                    
                    <p>If-else statement:<br>
                    &#123;% if is_admin %&#125;<br>
                    &nbsp;&nbsp;User is an admin.<br>
                    &#123;% else %&#125;<br>
                    &nbsp;&nbsp;User is not an admin.<br>
                    &#123;% endif %&#125;</p>
                </div>
            </div>
            
            <div class="example">
                <h2>Truthy and Falsy Values</h2>
                <p>The following values are considered "true":</p>
                <ul>
                    <li>"1", "true", "yes", "y", "on" and any non-empty string not explicitly false</li>
                </ul>
                
                <p>The following values are considered "false":</p>
                <ul>
                    <li>"0", "false", "no", "n", "off" and empty strings</li>
                </ul>
                
                <h3>Examples:</h3>
                <ul>
                    <li class="true">has_subscription (value: "{{has_subscription}}") is TRUE</li>
                    
                    <li class="true">status (value: "{{status}}") is TRUE</li>
                    
                    <li class="false">empty_var (value: "{{empty_var}}") is FALSE</li>
                </ul>
            </div>
            
            <div class="example">
                <h2>Nested Conditions</h2>
                
                <p class="true">User is logged in.</p>
                <p class="false">User has regular privileges.</p>
                <p class="true">User has an active subscription.</p>
                
                <h3>How it works:</h3>
                <div class="code">
                    <p>You can nest conditions inside other conditions:<br>
                    &#123;% if is_logged_in %&#125;<br>
                    &nbsp;&nbsp;User is logged in.<br>
                    &nbsp;&nbsp;&#123;% if is_admin %&#125;<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;User has admin privileges.<br>
                    &nbsp;&nbsp;&#123;% else %&#125;<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;User has regular privileges.<br>
                    &nbsp;&nbsp;&#123;% endif %&#125;<br>
                    &#123;% endif %&#125;</p>
                </div>
            </div>
        </div>
    </div>
    
    <footer>
        <div class="container">
            Blink Template Engine - Conditionals Examples
        </div>
    </footer>
</body>
</html>